task :build_mxp do

  require "erb"

  major_version = "0"
  minor_version = "0"
  %x(svn update)
  revision = `svn info --xml|grep revision`.chomp.match(/(\s+)revision=\"(\d+)\"/)[2]

  MXI_VERSION = "#{major_version}.#{minor_version}.#{revision}"

  open("iPhone_UI.mxi","w") do |f|
    f << ERB.new(IO.read("iPhone UI.mxirb")).result
  end
  # Pack with Extension Manager CS3
  %x(cp iPhone_UI.mxi iPhone_UI_CS3.mxi)
  %x(open -W 'iPhone_UI_CS3.mxi' -a "Extension Manager.app")
  %x(rm iPhone_UI_CS3.mxi)

  # Pack with Extension Manager CS4
  %x(cp iPhone_UI.mxi iPhone_UI_CS4.mxi)
  %x(open -W 'iPhone_UI_CS4.mxi' -a "Adobe Extension Manager CS4.app")
  %x(rm iPhone_UI_CS4.mxi)
end

task :default => :build_mxp